﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListConnection
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> items = new List<string>();

            items.Add("yellow");
            items.Insert(0, "red");

            Display(items, "Display the message:");

            items.Add("black");
            items.Add("green");
            items.Add("yellow");

            items.Remove("yellow");
            Display(items, "List after removing the color of yellow:");

            items.RemoveAt(2);
            Display(items, "List after removing the item whose index is 2:");

            Console.WriteLine("\"red\" is {0} in the list", items.Contains("red") ? string.Empty : "not");

            Console.WriteLine("Count:{0}", items.Count);
            Console.WriteLine("Capacity:{0}", items.Capacity);
            Console.ReadKey();
        }//end main

        public static void Display(List<string> result, string header)
        {
            Console.Write(header);

            foreach (var element in result)
            {
                Console.Write("{0}  ", element);
            }//end for

            Console.WriteLine();
        }//end method Display
    }
}
